package spotGUI.floatingChatGUI;

import javax.swing.ImageIcon;
import javax.swing.JEditorPane;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.text.DefaultEditorKit;
import java.util.ResourceBundle;

public class EditorPopup extends JPopupMenu {

	private JMenuItem mntmCut;
	private JMenuItem mntmCopy;
	private JMenuItem mntmPaste;
	private JSeparator separator;
	private JMenuItem mntmSelectAll;
	private JMenuItem mntmDeleteAll;
	
	private JEditorPane editor;
	
	public EditorPopup (JEditorPane editor) {

		this.editor = editor;
		
		mntmCut = new JMenuItem(editor.getActionMap().get(DefaultEditorKit.cutAction));
		mntmCut.setText(ResourceBundle.getBundle("spotGUI.floatingChatGUI.messages").getString("EditorPopup.mntmCut.text")); //$NON-NLS-1$ //$NON-NLS-2$
		mntmCut.setIcon(new ImageIcon(SingleConversationPanel.class.getResource("/images/textIcons/cut.png")));
		add(mntmCut);

		mntmCopy = new JMenuItem(editor.getActionMap().get(DefaultEditorKit.copyAction));
		mntmCopy.setText(ResourceBundle.getBundle("spotGUI.floatingChatGUI.messages").getString("EditorPopup.mntmCopy.text")); //$NON-NLS-1$ //$NON-NLS-2$
		mntmCopy.setIcon(new ImageIcon(SingleConversationPanel.class.getResource("/images/textIcons/copy.png")));
		add(mntmCopy);

		mntmPaste = new JMenuItem(editor.getActionMap().get(DefaultEditorKit.pasteAction));
		mntmPaste.setText(ResourceBundle.getBundle("spotGUI.floatingChatGUI.messages").getString("EditorPopup.mntmPaste.text")); //$NON-NLS-1$ //$NON-NLS-2$
		mntmPaste.setIcon(new ImageIcon(SingleConversationPanel.class.getResource("/images/textIcons/paste.png")));
		add(mntmPaste);

		separator = new JSeparator();
		add(separator);

		mntmSelectAll = new JMenuItem(editor.getActionMap().get(DefaultEditorKit.selectAllAction));
		mntmSelectAll.setText(ResourceBundle.getBundle("spotGUI.floatingChatGUI.messages").getString("EditorPopup.mntmSelectAll.text")); //$NON-NLS-1$ //$NON-NLS-2$
		mntmSelectAll.setIcon(new ImageIcon(SingleConversationPanel.class.getResource("/images/textIcons/select_all.png")));
		add(mntmSelectAll);

		mntmDeleteAll = new JMenuItem();
		mntmDeleteAll.setText(ResourceBundle.getBundle("spotGUI.floatingChatGUI.messages").getString("EditorPopup.mntmDeleteAll.text")); //$NON-NLS-1$ //$NON-NLS-2$
		mntmDeleteAll.addActionListener(editor.getActionMap().get(DefaultEditorKit.deletePrevCharAction));
		mntmDeleteAll.addActionListener(editor.getActionMap().get(DefaultEditorKit.selectAllAction));
		mntmDeleteAll.setIcon(new ImageIcon(SingleConversationPanel.class.getResource("/images/textIcons/remove_format.png")));
		add(mntmDeleteAll);

	}
}
